package com.situ.mall.controller.front;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.situ.mall.entity.Product;
import com.situ.mall.service.IProductService;

@Controller
@RequestMapping("/product")
public class FrontProductController {
	@Autowired
	private IProductService productService;
	
	@RequestMapping("/getProductListPage.shtml")
	public String getProductListPage(Integer categoryId,Model model) {
		System.out.println("FrontProductController.getProductListPage()");
		List<Product> list = productService.getProductListPage(categoryId);
		model.addAttribute("list", list);
		
		return "/jsp/front/product_list.jsp";
	}
	
	@RequestMapping("selectByProductId.shtml")
	public String selectByProductId(Integer id , Model model) {
		System.out.println("FrontProductController.selectByProductId()");
		Product product = productService.selectByProductId(id);
		model.addAttribute("product", product);
		
		return "/jsp/front/product_detail.jsp";
	}
}
